﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="EntityInfoSchema"
    targetNamespace="http://www.dimotta.net/EntityInfoSchema12.xsd"
    elementFormDefault="qualified"
    xmlns="http://www.dimotta.net/EntityInfoSchema11.xsd"
    xmlns:mstns="http://www.dimotta.net/EntityInfoSchema12.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <xs:element name="entityInfo">
    <xs:complexType>       
      <xs:sequence minOccurs="1" maxOccurs="1">

        <xs:element name="aliases" minOccurs="0" maxOccurs="1">
          <xs:complexType>
            <xs:sequence>

              <xs:element name="alias" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:attribute name="id" use="required"></xs:attribute>
                </xs:complexType>
              </xs:element>

            </xs:sequence>
          </xs:complexType>
        </xs:element>
        
      <xs:element name="sqlStatements" minOccurs="1" maxOccurs="1">
          <xs:complexType>
            <xs:sequence>
              
              <xs:choice maxOccurs="unbounded">                
                <xs:element name="changeStatement" maxOccurs="unbounded">
                  <xs:complexType>
                    <xs:sequence minOccurs="1" maxOccurs="1">
                      <xs:element name="command" nillable="false"></xs:element>
                    </xs:sequence>
                    <xs:attribute name="id" use="required"></xs:attribute>
                    <xs:attribute name="parameterMap" use="optional"></xs:attribute>
                  </xs:complexType>
                </xs:element>
                
                <xs:element name="selectStatement" maxOccurs="unbounded">
                  <xs:complexType>
                    <xs:sequence minOccurs="1" maxOccurs="1">
                      <xs:element name="command" nillable="false"></xs:element>
                    </xs:sequence>
                    <xs:attribute name="id" use="required"></xs:attribute>
                    <xs:attribute name="resultMap" use="required"></xs:attribute>
                    <xs:attribute name="parameterMap" use="optional"></xs:attribute>
                  </xs:complexType>
                </xs:element>

                <xs:element name="singleSelectStatement" maxOccurs="unbounded">
                  <xs:complexType>
                    <xs:sequence minOccurs="1" maxOccurs="1">
                      <xs:element name="command" nillable="false"></xs:element>
                    </xs:sequence>
                    <xs:attribute name="id" use="required"></xs:attribute>
                    <xs:attribute name="resultMap" use="required"></xs:attribute>
                    <xs:attribute name="parameterMap" use="optional"></xs:attribute>
                  </xs:complexType>
                </xs:element>

                <xs:element name="storedProcedure" minOccurs="0" maxOccurs="unbounded">
                  <xs:complexType>
                    <xs:attribute name="id" use="required"></xs:attribute>
                    <xs:attribute name="name" use="required"></xs:attribute>
                    <xs:attribute name="parameterMap" use="optional"></xs:attribute>
                  </xs:complexType>
                </xs:element>
                
              </xs:choice>
            </xs:sequence>            
          </xs:complexType>        
        </xs:element>        
        
        <xs:element name="maps" minOccurs="1" maxOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:choice maxOccurs="unbounded">

                <xs:element name="resultMap" minOccurs="0" maxOccurs="unbounded">
                  <xs:complexType>
                    <xs:sequence>
                      <xs:element name="fields" minOccurs="1" maxOccurs="1">
                        <xs:complexType>
                          <xs:sequence minOccurs="1" maxOccurs="unbounded">
                            <xs:element name="field">
                              <xs:complexType>
                                <xs:attribute name="property" use="required"></xs:attribute>
                                <xs:attribute name="column" use="required"></xs:attribute>                                
                              </xs:complexType>
                            </xs:element>
                          </xs:sequence>
                        </xs:complexType>
                      </xs:element>                      
                    </xs:sequence>
                    <xs:attribute name="id" use="required"></xs:attribute>
                  </xs:complexType>
                  
                </xs:element>
                <xs:element name="parameterMap" minOccurs="0" maxOccurs="unbounded">
                  
                  <xs:complexType>                    
                    <xs:sequence>                      
                      <xs:element name="params" minOccurs="1" maxOccurs="1">
                        <xs:complexType>
                          <xs:sequence minOccurs="1" maxOccurs="unbounded">
                            <xs:element name="param">
                              <xs:complexType>
                                <xs:attribute name="name" use="required"></xs:attribute>
                                <xs:attribute name="property" use="required"></xs:attribute>
                              </xs:complexType>
                            </xs:element>
                          </xs:sequence>
                        </xs:complexType>
                      </xs:element>
                    </xs:sequence>
                    <xs:attribute name="id" use="required"></xs:attribute>
                  </xs:complexType>
                </xs:element>
                
              </xs:choice>              
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        
      </xs:sequence>       
    </xs:complexType>    
  </xs:element>
</xs:schema>
